#include <bits/stdc++.h>
#define ps putchar(' ')
#define pe putchar('\n')
// #define int long long
//  #define ls p << 1
//  #define rs p << 1 | 1
//  #define mid ((l + r) >> 1)
using namespace std;
inline int read()
{
    int ans = 0, f = 0;
    char c = getchar();
    while (!isdigit(c))
        f |= c == '-', c = getchar();
    while (isdigit(c))
        ans = (ans << 3) + (ans << 1) + c - 48, c = getchar();
    return f ? -ans : ans;
}
void write(int x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        write(x / 10);
    putchar(x % 10 + 48);
}
const int N = 1e6 + 5;
int n, k, ans, fa[N][20];
int d[N], id[N], vis[N]; // depth
vector<int> g[N];
struct Path
{
    int cnt, dfn[N], top[N], si[N], son[N];
    struct BIT
    {
        int t[N];
        inline void add(int k, int w)
        {
            while (k <= n)
                t[k] += w, k += k & -k;
        }
        inline int ask(int k)
        {
            int ans = 0;
            while (k)
                ans += t[k], k -= k & -k;
            return ans;
        }
        inline int ask(int l, int r) { return ask(r) - ask(l - 1); }
    } bit;
    void dfs(int u) // also initialize d[]
    {
        si[u] = 1;
        for (int v : g[u])
        {
            d[v] = d[u] + 1, dfs(v), si[u] += si[v];
            if (si[son[u]] < si[v])
                son[u] = v;
        }
    }
    void dfs(int u, int Top)
    {
        dfn[u] = ++cnt, top[u] = Top;
        if (!son[u])
            return;
        dfs(son[u], Top);
        for (int v : g[u])
            if (v != son[u])
                dfs(v, v);
    }
    inline void init() { dfs(1), dfs(1, 1); }
    inline void add(int u, int w) { bit.add(dfn[u], w); }
    inline bool ask(int u, int v)
    {
        int ans = 0;
        while (top[u] != top[v])
        {
            if (d[top[u]] < d[top[v]])
                swap(u, v);
            if (bit.ask(dfn[top[u]], dfn[u]))
                return 1;
            u = fa[top[u]][0];
        }
        if (d[u] > d[v])
            swap(u, v);
        return bit.ask(dfn[u], dfn[v]);
    }
} path;
// inline void up_original(int u)
// {
//     int step = 0;
//     while (u != 1)
//     {
//         if (step == k - 1 || vis[u])
//         {
//             vis[u] = 1;
//             break;
//         }
//         u = fa[u][0], ++step;
//     }
// }
inline void up_advanced(int u)
{
    if (d[u] <= k || vis[u])
        return;
    int v = u; // target
    for (int i = 19; i >= 0; --i)
        if (fa[v][i] && d[u] - d[fa[v][i]] <= k - 1)
            v = fa[v][i];
    if (!path.ask(u, v) && !vis[v])
        path.add(v, vis[v] = 1), ++ans;
}
signed main()
{
    freopen("lost.in", "r", stdin);
    freopen("lost.out", "w", stdout);
    n = read(), k = read();
    ans = read() != 1, id[1] = 1;
    for (int i = 2; i <= n; ++i)
        g[fa[i][0] = read()].push_back(id[i] = i);
    for (int j = 1; j <= 19; ++j)
        for (int i = 1; i <= n; ++i)
            fa[i][j] = fa[fa[i][j - 1]][j - 1];
    path.init();
    sort(id + 1, id + n + 1, [](int x, int y)
         { return d[x] > d[y]; });
    for (int i = 1; i < n; ++i)
        up_advanced(id[i]);
    write(ans);
    return 0;
}
